<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>应用题列表</title>
    <script src="../static/js/jquery.min.js"></script>
</head>
<body>
<table border="1px" class="layui-table">
    <tr>
        <th>编号</th>
        <th>试题内容</th>
        <th>答案</th>
        <th>操作</th>
    </tr>
    <tbody id="choiceData">
    </tbody>
</table><br>
<script>
    $.post("/test/BigList",{"page":1,"limit":10},function (res) {
        console.log(res);
        var bigList = res.bigList;
        for (var i=0;i<bigList.length;i++){
            var bigQst = bigList[i];
            var trTag = document.createElement("tr");
            var td1 = document.createElement("td");
            td1.innerHTML = bigQst.bigQuestion;
            var td2 = document.createElement("td");
            var text1 = document.createElement("textarea");
            text1.className = td1.innerHTML;
            text1.innerHTML = bigQst.bigInfo;
            td2.appendChild(text1);
            var td3 = document.createElement("td");
            var text2 = document.createElement("textarea");
            text2.className = td1.innerHTML;
            text2.innerHTML = bigQst.bigAnsw;
            td3.appendChild(text2);
            var td4 = document.createElement("td");
            var btn1 = document.createElement("button");
            btn1.innerText = "修改";
            btn1.id = td1.innerHTML;
            btn1.onclick = function () {
                var bigQuestion = this.id;
                var bigInfo = $("."+this.id)[0].innerHTML;
                var bigAnsw = $("."+this.id)[1].innerHTML;
                $.post("/test/updateBigTest",{"BigQuestion":bigQuestion,"BigInfo":bigInfo,"BigAnsw":bigAnsw},function (res) {
                    window.location.reload(true);
                })
            }
            var btn2 = document.createElement("button");
            btn2.innerText = "删除";
            btn2.name = td1.innerHTML;
            btn2.onclick = function(){
                var bigQuestion = this.name;
                $.post("/test/deleteBigTest",{"bigQuestion":bigQuestion},function (res) {
                    window.location.reload(true);
                })
            }
            td4.appendChild(btn1);
            td4.appendChild(btn2);

            trTag.appendChild(td1);
            trTag.appendChild(td2);
            trTag.appendChild(td3);
            trTag.appendChild(td4);

            document.getElementById("choiceData").appendChild(trTag);

        }
    },"json");

</script>
</body>
</html>